Re: [GENERAL] one problem
От | Stuart Rison |
---|---|
Тема | Re: [GENERAL] one problem |
Дата | |
Msg-id | v04020a01b3a7a80a5e25@[128.40.242.190] обсуждение исходный текст |
Ответ на | Re: [GENERAL] one problem ("Jonathan davis" <haj@idianet.net>) |
Список | pgsql-general |
>>Hello all >> >>how to get back one database (text format) to postgresql ? >> >>field1 field2 field3 ... >>field1 field2 field3 ... >>. >>. >>. >> >>thanks >> > > >the COPY command does that BUT BUT BUT BUT !!! >how to specify the fields for example I just insert field2 into the >database > >example: > >create table country (code char(2), country char(20)); > >and i want to insert just the field country not the field code > >how to proceed ? Salut Jonathan, Hum... don't think you could do that with a COPY in one step you could COPY all of that data into a temp table and then INSERT the fields you want into the final table and delete the old ones so: (in psql) CREATE TABLE temp_copy (field1 text, field2 text, field3 text); -- obviously, use the right types COPY temp_copy FROM <text_format_database>; INSERT INTO country (country) SELECT field2 FROM temp_copy; -- or whatever field or fields you want, -- you could also use SELECT INTO command to create TABLE country on the fly and alter it with ALTER TABLE if necessary. DROP TABLE temp_copy; HTH, Stuart. +-------------------------+--------------------------------------+ | Stuart Rison | Ludwig Institute for Cancer Research | +-------------------------+ 91 Riding House Street | | Tel. (0171) 878 4041 | London, W1P 8BT, UNITED KINGDOM. | | Fax. (0171) 878 4040 | stuart@ludwig.ucl.ac.uk | +-------------------------+--------------------------------------+
В списке pgsql-general по дате отправления: